<template>
  <div class="page-container">
    <!--工具栏-->
    <div class="toolbar" style="float:left;padding-top:10px;padding-left:15px;width: 100%;">
      <!--顶部抽奖步骤栏-->
      <el-steps :active="active" finish-status="success" simple style="margin-top: 20px">
        <el-step title="1、设置抽奖规则"></el-step>
        <el-step title="2、奖品设置"></el-step>
        <el-step title="3、提交审核"></el-step>
      </el-steps>

      <!-- 第一步 设置抽奖规则 -->
      <div v-show="active == 1">
        <el-form ref="lotteryInfoForm" :model="lotteryInfoForm" :rules="lotteryInfoFormRules" label-width="100px" class="form-horizontal mgt15">
          <!-- 基本信息 -->
          <div style="width:78%">
            <div class="title">基本信息</div>
            <div class="item">
                <el-row>
                    <el-form-item label="活动名称：" prop="activityName">
                      <el-input v-model.trim="lotteryInfoForm.activityName" placeholder="限制在60个字符以内" size="mini" minlength="3" maxlength="60" class="inputWidth"></el-input>
                    </el-form-item>
                </el-row>
                <el-row>
                  <el-form-item label="活动时间：" prop="promotionStartEndTime" style="padding-top:10px;">
                    <div style="width:100%;">
                      <el-date-picker
                        v-model="lotteryInfoForm.promotionStartEndTime"
                        type="datetimerange"
                        range-separator="至"
                        start-placeholder="开始时间"
                        end-placeholder="结束时间"
                        size="mini"
                        format="yyyy-MM-dd HH:mm:ss"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        :picker-options="timeCheck"
                      ></el-date-picker>
                    </div>
                  </el-form-item>
                </el-row>
                <el-row>
                    <el-form-item label="抽奖模板：" prop="lotteryTemplate">
                      <el-select  v-model="lotteryInfoForm.lotteryTemplate" size="mini">
                        <el-option value="1" label="大转盘"></el-option>
                      </el-select>
                    </el-form-item>
                </el-row>
                <el-row>
                  <el-form-item label="是否分摊：" prop="costAllocationFlag">
                      <el-radio-group v-model="lotteryInfoForm.costAllocationFlag" prop="costAllocationFlag" @change="costAllocationFlagFun">
                        <el-radio v-model="lotteryInfoForm.costAllocationFlag" label="1" checked="true" name="type" value="1">是</el-radio>
                        <el-radio v-model="lotteryInfoForm.costAllocationFlag" label="2" name="type" value="2">否</el-radio>
                      </el-radio-group>
                      <div v-if="lotteryInfoForm.costAllocationFlag == '1'">
                          <span>母平台比例</span>
                          <el-input v-model.number="lotteryInfoForm.parentAllocationScale" auto-complete="off" type="text" :size="size" style="width:50px;"></el-input>
                          <span>%</span>
                          <span style="margin-left:10px;">子平台比例</span>
                          <el-input v-model.number="lotteryInfoForm.childAllocationScale" auto-complete="off" type="text" :size="size" style="width:50px;"></el-input>
                          <span>%</span>
                          <span style="margin-left:10px;">商家比例</span>
                          <el-input v-model.number="lotteryInfoForm.merchantAllocationScale" auto-complete="off" type="text" :size="size" style="width:50px;"></el-input>
                          <span>%</span>
                          <span style="margin-left:10px;">店铺比例</span>
                          <el-input v-model.number="lotteryInfoForm.storeAllocationScale" auto-complete="off" type="text" :size="size" style="width:50px;"></el-input>
                          <span>%</span>
                      </div>
                  </el-form-item>
                </el-row>
                <el-row>
                    <el-form-item label="活动标签：">
                        <el-select v-model="lotteryInfoForm.labelId" placeholder="请选择" size="mini">
                            <el-option
                                v-for="item in tagsList"
                                :key="item.id"
                                :label="item.tagName"
                                :value="item.id">
                            </el-option>
                        </el-select>
                        <el-button type="primary" @click="addtags" size="mini">添加标签</el-button>
                    </el-form-item>
                </el-row>
                <el-row>
                    <el-form-item label="活动描述：" prop="activityDesc">
                      <quill-editor v-model="lotteryInfoForm.activityDesc" ref="myQuillEditor" style="height: 300px;margin-bottom: 45px;margin-top: 10px;" :options="editorOption"></quill-editor>
                    </el-form-item>
                </el-row>
            </div>
          </div>
          
          <!-- 活动规则 -->
          <div style="width:78%">
            <div class="title" style="margin-top: 70px;">活动规则</div>
            <div class="item">
                <el-row>
                    <el-form-item label="抽奖活动类型：" label-width="180px" prop="lotteryType">
                      <el-radio-group v-model="lotteryInfoForm.lotteryType">
                        <el-radio :label="1" class="form-radio">普通抽奖</el-radio>
                        <el-radio :label="2" class="form-radio">订单抽奖</el-radio>
                      </el-radio-group>
                      <el-checkbox v-model="lotteryInfoForm.orderDrawModel" true-label="2" false-label="1" v-show="lotteryInfoForm.lotteryType==2" style="margin-bottom: 5px;margin-left: 30px;"> 仅支付已完成订单可参与抽奖</el-checkbox>
                    </el-form-item>
                </el-row>
                <el-row v-show="lotteryInfoForm.lotteryType==1">
                    <el-form-item label="每次抽奖需消耗：" label-width="180px" prop="drawPointsPerTime">
                      <el-input v-model="lotteryInfoForm.drawPointsPerTime" oninput="value=value.replace(/[^\d]/g,'')" size="mini" class="inputWidth"></el-input>
                    </el-form-item>
                </el-row>
                
                <el-row v-show="lotteryInfoForm.lotteryType==1">
                    <el-form-item label="免积分抽奖次数：" label-width="180px" prop="costFreeDrawTimes">
                      <el-input v-model="lotteryInfoForm.costFreeDrawTimes" oninput="value=value.replace(/[^\d]/g,'')" size="mini" class="inputWidth"></el-input>
                    </el-form-item>
                </el-row>
                <!--  单次消费订单金额X元 -->
                <el-row :gutter="20" v-show="lotteryInfoForm.lotteryType==2">
                    <el-col :span="10">
                        <el-radio v-model="lotteryInfoForm.orderDrawType" label="1">单次消费订单金额：</el-radio>
                        <el-input v-model.number="lotteryInfoForm.orderDrawAmountOne" oninput="value = value.match(/^\d*(\.?\d{0,2})/g)[0]" size="mini" :disabled="lotteryInfoForm.orderDrawType!=1" class="inputWidth"></el-input>
                            <label class="control-label ng-binding">元</label>
                    </el-col>
                    <el-col :span="10">
                      <el-form-item label="每个订单抽奖次数：" label-width="180px" prop="drawTimesPerOrderOne">
                        <el-input v-model.number="lotteryInfoForm.drawTimesPerOrderOne" oninput="value=value.replace(/[^\d]/g,'')" size="mini" maxlength="9" :disabled="lotteryInfoForm.orderDrawType!=1" class="inputWidth"></el-input>
                        <label class="control-label ng-binding">次</label>
                      </el-form-item>
                    </el-col>
                </el-row>
                <!--  消费订单金额每满X元 -->
                <el-row :gutter="20" v-show="lotteryInfoForm.lotteryType==2">
                    <el-col :span="10">
                            <el-radio v-model="lotteryInfoForm.orderDrawType" label="2">消费订单金额每满：</el-radio>
                            <el-input v-model.number="lotteryInfoForm.orderDrawAmountTwo" oninput="value = value.match(/^\d*(\.?\d{0,2})/g)[0]" size="mini" :disabled="lotteryInfoForm.orderDrawType!=2" class="inputWidth"></el-input>
                            <label class="control-label ng-binding">元</label>
                    </el-col>
                    <el-col :span="10">
                      <el-form-item label="可获得抽奖次数：" label-width="180px" prop="drawTimesPerOrderTwo">
                            <el-input v-model.number="lotteryInfoForm.drawTimesPerOrderTwo" oninput="value=value.replace(/[^\d]/g,'')" size="mini" maxlength="9" :disabled="lotteryInfoForm.orderDrawType!=2" class="inputWidth"></el-input>
                            <label class="control-label ng-binding">次</label>
                      </el-form-item>
                    </el-col>
                </el-row>
                <!--  累计消费订单金额X元 -->
                <el-row :gutter="20" v-show="lotteryInfoForm.lotteryType==2">
                    <el-col :span="10">
                            <el-radio v-model="lotteryInfoForm.orderDrawType" label="3">累计消费订单金额：</el-radio>
                            <el-input v-model.number="lotteryInfoForm.orderDrawAmountThree" oninput="value = value.match(/^\d*(\.?\d{0,2})/g)[0]" size="mini" :disabled="lotteryInfoForm.orderDrawType!=3" class="inputWidth"></el-input>
                            <label class="control-label ng-binding">元</label>
                    </el-col>
                    <el-col :span="10">
                      <el-form-item label="可获得抽奖次数：" label-width="180px" prop="drawTimesPerOrderThree">
                            <el-input v-model.number="lotteryInfoForm.drawTimesPerOrderThree" oninput="value=value.replace(/[^\d]/g,'')" size="mini" maxlength="9" :disabled="lotteryInfoForm.orderDrawType!=3" class="inputWidth"></el-input>
                            <label class="control-label ng-binding">次</label>
                      </el-form-item>
                    </el-col>
                </el-row>
                
                <el-row>
                  <el-form-item label="用户每日抽奖次数上限：" label-width="180px" prop="dailyDrawTimesLimit">
                      <el-input v-model.number="lotteryInfoForm.dailyDrawTimesLimit" oninput="value=value.replace(/[^\d]/g,'')" size="mini" class="inputWidth"></el-input>
                  </el-form-item>
                </el-row>
                <el-row>
                  <el-form-item label="用户每日中奖次数上限：" label-width="180px" prop="dailyWinningTimesLimit">
                      <el-input v-model.number="lotteryInfoForm.dailyWinningTimesLimit" oninput="value=value.replace(/[^\d]/g,'')" size="mini" class="inputWidth"></el-input>
                  </el-form-item>
                </el-row>
            </div>
          </div>
          <!-- 参与条件 -->
          <div style="width:78%">
            <div class="title" style="margin-top: 70px;">参与条件</div>
            <div class="item">
              <el-row>
                  <el-form-item label="新老用户：" prop="proUserType">
                      <!-- <el-radio-group v-model="lotteryInfoForm.proUserType"> -->
                          <el-radio v-model="lotteryInfoForm.proUserType" label="0" value="0">不限制</el-radio>
                          <el-radio v-model="lotteryInfoForm.proUserType" label="2" value="2">老用户</el-radio>
                          <el-radio v-model="lotteryInfoForm.proUserType" label="1" value="1">新用户</el-radio>
                      <!-- </el-radio-group> -->
                  </el-form-item>
              </el-row>
              <el-row v-if="deptType == 0">
                <el-form-item label="使用渠道：" class="wid" required>
                  <div style="width:100%;">
                    <el-tree :data="channelList" :props="channlProps" show-checkbox node-key="id" :default-expand-all="true" ref="channelTree"></el-tree>
                  </div>
                </el-form-item>
              </el-row>
              <el-row>
                  <el-form-item label="店铺地区：" prop="storeArea">
                      <el-radio v-model="lotteryInfoForm.storeArea" label="0" value="0">全国</el-radio>
                  </el-form-item>
              </el-row>
              <el-row>
                  <el-form-item label="用户地区：" prop="userArea">
                    <el-radio v-model="lotteryInfoForm.userArea" label="0" value="0">全国</el-radio>
                  </el-form-item>
              </el-row>
            </div>
          </div>
        </el-form>
      </div>

      <!-- 第二部 奖品设置 -->
      <div class="tab-container" v-if="active == 2">
        <el-container>
          <el-aside width="35%" style="min-width: 550px">
            <el-form :model="dynamicValidateForm" ref="dynamicValidateForm" label-width="100px" class="demo-dynamic" >
            <!--   1   -->
            <el-form-item class="one" style="margin-left: 20px;">
                  <el-form :model="dynamicValidateForm.dataForm0" label-width="80px" :rules="dataForm0Rules"  ref="dataForm0" :size="size">
                    <el-form-item label="奖项等级" prop="awardsLevel" style="width:100%">
                      <el-select v-model="dynamicValidateForm.dataForm0.awardsLevel" placeholder="请选择" style="width: 80%">
                        <el-option v-for="item in awardsLevelList"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="奖品类别" prop="awardsCategory">
                      <el-select v-model="dynamicValidateForm.dataForm0.awardsCategory" style="width: 80%" placeholder="请选择">
                        <el-option v-for="item in awardsCategoryList"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"></el-option>
                      </el-select>
                    </el-form-item>
                    <div v-show="dynamicValidateForm.dataForm0.awardsCategory === 2">
                      <el-form-item label="添加商品">
                        <el-button v-model="dynamicValidateForm.dataForm0.awardsRefId" plain @click="productClick(0)" style="width: 80%">添加商品</el-button>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm0.awardsCategory === 4">
                      <el-form-item label="积分">
                        <el-input v-model="dynamicValidateForm.dataForm0.awardsRefNum" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm0.awardsCategory === 3">
                      <el-form-item label="优惠券">
                        <el-button v-model="dynamicValidateForm.dataForm0.awardsRefId" plain @click="couponClick(0)" style="width: 80%">添加优惠券</el-button>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm0.awardsCategory !== 1">
                      <el-form-item label="奖品名称">
                        <el-input v-model="dynamicValidateForm.dataForm0.awardsRefName" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm0.awardsCategory !== 1">
                      <el-form-item label="奖品数量">
                        <el-input v-model="dynamicValidateForm.dataForm0.winningNum" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <el-form-item label="中奖率" prop="winningRate">
                      <el-input v-model="dynamicValidateForm.dataForm0.winningRate" style="width: 80%"></el-input><span style="margin-left: 10px;">%</span>
                    </el-form-item>
                  </el-form>
              <div class="lineDev"></div>
              </el-form-item>
            <!--   2   -->
              <el-form-item class="one" style="margin-left: 20px;">
                  <el-form :model="dynamicValidateForm.dataForm1" label-width="80px" :size="size">
                    <el-form-item label="奖项等级">
                      <el-select v-model="dynamicValidateForm.dataForm1.awardsLevel" placeholder="请选择" style="width: 80%">
                        <el-option v-for="item in awardsLevelList"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="奖品类别">
                      <el-select v-model="dynamicValidateForm.dataForm1.awardsCategory" style="width: 80%" placeholder="请选择">
                        <el-option v-for="item in awardsCategoryList"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"></el-option>
                      </el-select>
                    </el-form-item>
                    <div v-show="dynamicValidateForm.dataForm1.awardsCategory === 2">
                      <el-form-item label="添加商品">
                        <el-button v-model="dynamicValidateForm.dataForm1.awardsRefId" plain @click="productClick(1)" style="width: 80%">添加商品</el-button>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm1.awardsCategory === 4">
                      <el-form-item label="积分">
                        <el-input v-model="dynamicValidateForm.dataForm1.awardsRefNum" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm1.awardsCategory === 3">
                      <el-form-item label="优惠券">
                        <el-button v-model="dynamicValidateForm.dataForm1.awardsRefId" plain @click="couponClick(1)" style="width: 80%">添加优惠券</el-button>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm1.awardsCategory !== 1">
                      <el-form-item label="奖品名称">
                        <el-input v-model="dynamicValidateForm.dataForm1.awardsRefName" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm1.awardsCategory !== 1">
                      <el-form-item label="奖品数量">
                        <el-input v-model="dynamicValidateForm.dataForm1.winningNum" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <el-form-item label="中奖率">
                      <el-input v-model="dynamicValidateForm.dataForm1.winningRate" style="width: 80%"></el-input><span style="margin-left: 10px;">%</span>
                    </el-form-item>
                  </el-form>
               <div class="lineDev"></div>
              </el-form-item>
              
            <!--   3   -->
              <el-form-item class="one" style="margin-left: 20px;">
                  <el-form :model="dynamicValidateForm.dataForm2" label-width="80px" :size="size">
                    <el-form-item label="奖项等级">
                      <el-select v-model="dynamicValidateForm.dataForm2.awardsLevel" placeholder="请选择" style="width: 80%">
                        <el-option v-for="item in awardsLevelList"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="奖品类别">
                      <el-select v-model="dynamicValidateForm.dataForm2.awardsCategory" style="width: 80%" placeholder="请选择">
                        <el-option v-for="item in awardsCategoryList"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"></el-option>
                      </el-select>
                    </el-form-item>
                    <div v-show="dynamicValidateForm.dataForm2.awardsCategory === 2">
                      <el-form-item label="添加商品">
                        <el-button v-model="dynamicValidateForm.dataForm2.awardsRefId" plain @click="productClick(2)" style="width: 80%">添加商品</el-button>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm2.awardsCategory === 4">
                      <el-form-item label="积分">
                        <el-input v-model="dynamicValidateForm.dataForm2.awardsRefNum" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm2.awardsCategory === 3">
                      <el-form-item label="优惠券">
                        <el-button v-model="dynamicValidateForm.dataForm2.awardsRefId" plain @click="couponClick(2)" style="width: 80%">添加优惠券</el-button>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm2.awardsCategory !== 1">
                      <el-form-item label="奖品名称">
                        <el-input v-model="dynamicValidateForm.dataForm2.awardsRefName" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm2.awardsCategory !== 1">
                      <el-form-item label="奖品数量">
                        <el-input v-model="dynamicValidateForm.dataForm2.winningNum" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <el-form-item label="中奖率">
                      <el-input v-model="dynamicValidateForm.dataForm2.winningRate" style="width: 80%"></el-input><span style="margin-left: 10px;">%</span>
                    </el-form-item>
                  </el-form>
                <div class="lineDev"></div>
              </el-form-item>
              
            <!--   4   -->
              <el-form-item class="one" style="margin-left: 20px;">
                  <el-form :model="dynamicValidateForm.dataForm3" label-width="80px" :size="size">
                    <el-form-item label="奖项等级">
                      <el-select v-model="dynamicValidateForm.dataForm3.awardsLevel" placeholder="请选择" style="width: 80%">
                        <el-option v-for="item in awardsLevelList"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="奖品类别">
                      <el-select v-model="dynamicValidateForm.dataForm3.awardsCategory" style="width: 80%" placeholder="请选择">
                        <el-option v-for="item in awardsCategoryList"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"></el-option>
                      </el-select>
                    </el-form-item>
                    <div v-show="dynamicValidateForm.dataForm3.awardsCategory === 2">
                      <el-form-item label="添加商品">
                        <el-button v-model="dynamicValidateForm.dataForm3.awardsRefId" plain @click="productClick(3)" style="width: 80%">添加商品</el-button>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm3.awardsCategory === 4">
                      <el-form-item label="积分">
                        <el-input v-model="dynamicValidateForm.dataForm3.awardsRefNum" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm3.awardsCategory === 3">
                      <el-form-item label="优惠券">
                        <el-button v-model="dynamicValidateForm.dataForm3.awardsRefId" plain @click="couponClick(3)" style="width: 80%">添加优惠券</el-button>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm3.awardsCategory !== 1">
                      <el-form-item label="奖品名称">
                        <el-input v-model="dynamicValidateForm.dataForm3.awardsRefName" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm3.awardsCategory !== 1">
                      <el-form-item label="奖品数量">
                        <el-input v-model="dynamicValidateForm.dataForm3.winningNum" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <el-form-item label="中奖率">
                      <el-input v-model="dynamicValidateForm.dataForm3.winningRate" style="width: 80%"></el-input><span style="margin-left: 10px;">%</span>
                    </el-form-item>
                  </el-form>
                 <div class="lineDev"></div>
              </el-form-item>
             
            <!--   5   -->
              <el-form-item class="one" style="margin-left: 20px;">
                  <el-form :model="dynamicValidateForm.dataForm4" label-width="80px" :size="size">
                    <el-form-item label="奖项等级">
                      <el-select v-model="dynamicValidateForm.dataForm4.awardsLevel" placeholder="请选择" style="width: 80%">
                        <el-option v-for="item in awardsLevelList"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="奖品类别">
                      <el-select v-model="dynamicValidateForm.dataForm4.awardsCategory" style="width: 80%" placeholder="请选择">
                        <el-option v-for="item in awardsCategoryList"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"></el-option>
                      </el-select>
                    </el-form-item>
                    <div v-show="dynamicValidateForm.dataForm4.awardsCategory === 2">
                      <el-form-item label="添加商品">
                        <el-button v-model="dynamicValidateForm.dataForm4.awardsRefId" plain @click="productClick(4)" style="width: 80%">添加商品</el-button>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm4.awardsCategory === 4">
                      <el-form-item label="积分">
                        <el-input v-model="dynamicValidateForm.dataForm4.awardsRefNum" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm4.awardsCategory === 3">
                      <el-form-item label="优惠券">
                        <el-button v-model="dynamicValidateForm.dataForm4.coupon4" plain @click="couponClick(4)" style="width: 80%">添加优惠券</el-button>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm4.awardsCategory !== 1">
                      <el-form-item label="奖品名称">
                        <el-input v-model="dynamicValidateForm.dataForm4.awardsRefName" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm4.awardsCategory !== 1">
                      <el-form-item label="奖品数量">
                        <el-input v-model="dynamicValidateForm.dataForm4.winningNum" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <el-form-item label="中奖率">
                      <el-input v-model="dynamicValidateForm.dataForm4.winningRate" style="width: 80%"></el-input><span style="margin-left: 10px;">%</span>
                    </el-form-item>
                  </el-form>
                <div class="lineDev"></div>
              </el-form-item>
              
            <!--   6   -->
              <el-form-item class="one" style="margin-left: 20px;">
                  <el-form :model="dynamicValidateForm.dataForm5" label-width="80px" :size="size">
                    <el-form-item label="奖项等级">
                      <el-select v-model="dynamicValidateForm.dataForm5.awardsLevel" placeholder="请选择" style="width: 80%">
                        <el-option v-for="item in awardsLevelList"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="奖品类别">
                      <el-select v-model="dynamicValidateForm.dataForm5.awardsCategory" style="width: 80%" placeholder="请选择">
                        <el-option v-for="item in awardsCategoryList"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"></el-option>
                      </el-select>
                    </el-form-item>
                    <div v-show="dynamicValidateForm.dataForm5.awardsCategory === 2">
                      <el-form-item label="添加商品">
                        <el-button v-model="dynamicValidateForm.dataForm5.awardsRefId" plain @click="productClick(5)" style="width: 80%">添加商品</el-button>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm5.awardsCategory === 4">
                      <el-form-item label="积分">
                        <el-input v-model="dynamicValidateForm.dataForm5.awardsRefNum" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm5.awardsCategory === 3">
                      <el-form-item label="优惠券">
                        <el-button v-model="dynamicValidateForm.dataForm5.awardsRefId" plain @click="couponClick(5)" style="width: 80%">添加优惠券</el-button>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm5.awardsCategory !== 1">
                      <el-form-item label="奖品名称">
                        <el-input v-model="dynamicValidateForm.dataForm5.awardsRefName" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <div v-show="dynamicValidateForm.dataForm5.awardsCategory !== 1">
                      <el-form-item label="奖品数量">
                        <el-input v-model="dynamicValidateForm.dataForm5.winningNum" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <el-form-item label="中奖率">
                      <el-input v-model="dynamicValidateForm.dataForm5.winningRate" style="width: 80%"></el-input><span style="margin-left: 10px;">%</span>
                    </el-form-item>
                  </el-form>
                <div class="lineDev"></div>
              </el-form-item>



              <!--新增的表单元素-->
              <div class="dialog-wrap" v-if="showNewAddDialog">
                <el-form-item class="one" style="margin-left: 20px;" v-for="item in dynamicValidateForm.domains" :key="item.id" >
                  <el-form :model="item.form" label-width="80px" :size="size">
                    <el-form-item label="奖项等级">
                      <el-select v-model="item.form.value" placeholder="请选择" style="width: 80%">
                        <el-option v-for="item2 in item.awardsLevelList"
                          :key="item2.id"
                          :label="item2.name"
                          :value="item2.id"></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="奖品类别">
                      <el-select v-model="item.form.awardsCategory" style="width: 80%" placeholder="请选择">
                        <el-option v-for="item2 in awardsCategoryList"
                          :key="item2.id"
                          :label="item2.name"
                          :value="item2.id"></el-option>
                      </el-select>
                    </el-form-item>
                    <div v-show="item.form.awardsCategory === 2">
                      <el-form-item label="添加商品">
                        <el-button v-model="item.form.awardsRefId" plain @click="productClick" style="width: 80%">添加商品</el-button>
                      </el-form-item>
                    </div>
                    <div v-show="item.form.awardsCategory === 4">
                      <el-form-item label="积分">
                        <el-input v-model="item.form.awardsRefNum" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <div v-show="item.form.awardsCategory === 3">
                      <el-form-item label="优惠券">
                        <el-button v-model="item.form.awardsRefId" plain @click="couponClick" style="width: 80%">添加优惠券</el-button>
                      </el-form-item>
                    </div>
                    <div v-show="item.form.awardsCategory !== 1">
                      <el-form-item label="奖品名称">
                        <el-input v-model="item.form.awardsRefName" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <div v-show="item.form.awardsCategory !== 1">
                      <el-form-item label="奖品数量">
                        <el-input v-model="item.form.winningNum" style="width: 80%"></el-input>
                      </el-form-item>
                    </div>
                    <el-form-item label="中奖率">
                      <el-input v-model="item.form.winningRate" style="width: 80%"></el-input><span style="margin-left: 10px;">%</span>
                    </el-form-item>
                    <el-form-item>
                      <el-button @click.prevent="removeDomain(item)" class="delete">删除</el-button>
                    </el-form-item>
                  </el-form>
                <div class="lineDev"></div>
              </el-form-item>
              </div>
              
            </el-form>

            <!-- 新增按钮 -->
            <!-- <div class="add-wrap">
              <el-button @click="addDomain" :disabled="addButtonDisabled">新增表单</el-button>
            </div> -->

            <!--   未中奖说明   -->
              <el-row style="margin-left: 20px;">
                  <el-form :model="dataForm7" label-width="100px" :size="size">
                    <el-form-item label="未中奖说明">
                      <el-input style="width: 90%" type="textarea" :rows="5" placeholder="请输入未中奖说明" v-model="dataForm7.notWinningDesc" maxlength="150" show-word-limit></el-input>
                    </el-form-item>
                  </el-form>
              </el-row>
          </el-aside>
          <el-main>
            <img src="/static/lottery.jpg" alt="">
          </el-main>
        </el-container>
      </div>

      <!-- 第三部 提交审核 -->
      <div class="tab-container" v-if="active == 3" style="text-align: center;margin-top: 5%;">
        <div>
            <img src="/static/images/success.png" style="width:20px;"/>
            <span style="font-size:25px;">创建成功!</span>
        </div>
        <div style="margin-top:20px;">
            <kt-button type="primary" label="提交审核" plain :size="size" v-show="status==1" perms="market:lottery:submit" @click="submitReview(0)"/>
            <kt-button type="primary" label="审核" plain :size="size" v-show="status==2" perms="market:lottery:verify" @click="review(1)"/>
            <kt-button type="primary" label="保存为模板" plain :size="size" @click="templateDialogFormVisible = true" perms="market:lottery:addtemp"/>
        </div>
        <div style="margin-top:20px;">
            <el-link type="primary" @click="viewList">查看抽奖活动列表</el-link>
        </div>
      </div>
      
    </div>

    <!-- 底部按钮 -->
    <div>
      <el-button type="primary" style="margin-top: 60px;margin-bottom: 60px;" v-if="active == 2" @click="upStep">上一步</el-button>
      <el-button type="primary" style="margin-top: 60px;margin-bottom: 60px;" v-if="active != 3" @click="next">下一步</el-button>
    </div>

    <!-- 添加商品弹窗 -->
    <el-dialog :visible.sync="dialogProductVisible" width="50%" title="添加商品">
        <el-tabs v-model="tabsIndex">
            <el-tab-pane label="商品管理" name="first">
                <el-form :inline="true" class="demo-form-inline2" size="small" v-model="formInline">
                    <el-row class="searchDialog-input">
                        <el-form-item label="商品名称：">
                            <el-input v-model="formInline.goodsName" placeholder="商品名称"></el-input>
                        </el-form-item>
                       <el-form-item label="商品编码：">
                            <el-input v-model="formInline.code" placeholder="商品编码"></el-input>
                        </el-form-item>
                       <el-form-item label="商品分类：">
                            <el-input v-model="formInline.goodsCategory" placeholder="商品分类"></el-input>
                        </el-form-item>
					          </el-row>
                    <el-row class="searchDialog-input">
                        <el-form-item label="商家名称：">
                            <el-input v-model="formInline.merchantName" placeholder="商家名称"></el-input>
                        </el-form-item>
                       <el-form-item label="店铺名称：">
                            <el-input v-model="formInline.storeName" placeholder="店铺名称"></el-input>
                        </el-form-item>
					          </el-row>
                    <el-row class="t_r mb20">
                        <el-form-item>
                            <el-button type="primary" icon="el-icon-search" @click="queryPageProductManagement">搜索</el-button>
                            <el-button icon="el-icon-refresh-left" @click="restForm">重置</el-button>
                        </el-form-item>
                    </el-row>
                </el-form>
                <div class="table-section" style="height: 400px;">
                    <el-table :data="productData" v-loading="productListloading"
                        :header-cell-style="tableHeaderColor"
                        ref="multipleTable"
                        style="width: 100%" 
                        height="350"
                        :row-class-name="tableRowClassName"
                        border
                        :size="size">
                        <el-table-column prop="id" label="商品ID" sortable  align="center"></el-table-column>
                        <el-table-column prop="goodsName" label="商品名称" align="center"></el-table-column>
                        <el-table-column prop="goodsCategory" label="商品类目" align="center"></el-table-column>
                        <el-table-column prop="merchantName" label="商家名称" align="center"></el-table-column>
                        <el-table-column prop="storeName" label="店铺名称" align="center"></el-table-column>
                        <el-table-column prop="salePrice" label="原价（元）" align="center"></el-table-column>
                        <el-table-column label="操作" fixed="right" align="center">
                          <template slot-scope="scope">
                              <el-button
                                  :size="size"
                                  @click="selectProduct(scope.row,markProFlag)">选择</el-button>
                          </template>
                        </el-table-column>
                    </el-table>
                </div>
            </el-tab-pane>
        </el-tabs>
        <div slot="footer" class="dialog-footer">
            <div v-if="productData.length > 0" style="position:absolute;right: 20px;bottom:10px;">
                <el-pagination
                    @size-change="producthandleSizeChange"
                    @current-change="producthandleCurrentChange"
                    :current-page="formInline.start"
                    :page-sizes="[10]"
                    :page-size="formInline.limit"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="productListTotal">
                </el-pagination>
            </div>
            <!-- <el-button @click="dialogProductVisible=false" size="mini">关闭</el-button> -->
        </div>
    </el-dialog>

    <!--优惠券弹窗-->
    <el-dialog :title="'添加优惠券'" :inline="true" width="50%" :visible.sync="dialogCouponVisible" :close-on-click-modal="false">
      <el-form label-width="120px" :size="size">
        <el-form-item label="券活动名称：">
          <el-input v-model="promName" style="width: 30%"></el-input>
          <kt-button icon="fa fa-search" :label="$t('action.search')" type="primary" @click="queryPageCouponList"/>
          <kt-button icon="fa fa-refresh" :label="$t('action.reset')" type="primary" @click="resetForm('filters')" />
        </el-form-item>
      </el-form>
      <el-table :data="couponDataList" style="width:100%">
        <el-table-column fixed prop="id" label="优惠券活动ID"></el-table-column>
        <el-table-column fixed prop="promName" label="优惠券名称"></el-table-column>
        <el-table-column fixed="right" label="操作">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="selectCoupon(scope.row,markProFlag)">选择</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div v-if="productData.length > 0" style="position:static;right:20px;bottom:10px;padding-top: 16px;float: right;">
          <el-pagination
              @size-change="couponHandleSizeChange"
              @current-change="couponHandleCurrentChange"
              :current-page="couponformInline.start"
              :page-sizes="[10]"
              :page-size="couponformInline.limit"
              layout="total, sizes, prev, pager, next, jumper"
              :total="couponDataListTotal">
          </el-pagination>
      </div>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button :size="size" @click.native="dialogCouponVisible = false">取消</el-button>
      </div>
    </el-dialog>

    <el-dialog title="添加标签" :visible.sync="addTagDialogFormVisible" width="20%">
      <el-form :model="addTagForm" :rules="addTagRules" ref="addTagForm">
        <el-form-item label="标签分类：" :label-width="formLabelWidth" prop="categoryId">
              <el-select style="width:200px" v-model="addTagForm.categoryId" placeholder="请选择分类标签" size="mini">
                  <el-option
                  v-for="(item, index) in tagCategoryList"
                  :key="index"
                  :label="item.categoryName"
                  :value="item.id"
                  ></el-option>
              </el-select>
        </el-form-item>
          <el-form-item label="标签名称：" :label-width="formLabelWidth" prop="tagName">
              <el-input style="width:200px" placeholder="请输入标签名称" v-model.trim="addTagForm.tagName" size="mini"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="addTagDialogFormVisible=false" size="mini">取消</el-button>
        <el-button type="primary" @click="addNewTag" size="mini">确定</el-button>
      </div>
    </el-dialog>

    <!-- 审核弹窗 -->
    <el-dialog title="审核" :visible.sync="verifyDialogFormVisible">
      <el-form :model="verifyForm">
        <el-form-item label="审核理由：" :label-width="formLabelWidth">
          <el-input v-model.trim="verifyForm.checkRemark" autocomplete="off" type="textarea" rows = "6" placeholder="请输入审核理由"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="danger" @click="reviewDialog(2)" size="mini">审核拒绝</el-button>
        <el-button type="primary" @click="reviewDialog(1)" size="mini">审核通过</el-button>
      </div>
    </el-dialog>

    <!-- 模板弹窗 -->
    <el-dialog title="保存模板" :visible.sync="templateDialogFormVisible">
      <el-form :model="templateForm">
        <el-form-item label="模板名称：" :label-width="formLabelWidth">
          <el-input v-model.trim="templateForm.templateName" autocomplete="off" size="mini"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="danger" @click="templateDialogFormVisible=false" size="mini">取消</el-button>
        <el-button type="primary" @click="saveLotteryTemplate()" size="mini">保存模板</el-button>
      </div>
    </el-dialog>

  </div> 
</template>

<script>
  import KtButton from "@/views/Core/KtButton";
  import { format } from "@/utils/datetime";
  import TableColumnFilterDialog from "@/views/Core/TableColumnFilterDialog";
  import { darkmagenta } from "color-name";
  import { quillEditor } from "vue-quill-editor";
  import "quill/dist/quill.core.css";
  import "quill/dist/quill.snow.css";
  import "quill/dist/quill.bubble.css";
  export default {
    name: "Tab",
    components: {
      KtButton,
      TableColumnFilterDialog,
      quillEditor
    },
    data() {
      //活动时间验证
      var checkEffEndTime = (rule, value, callback) => {
        if(!this.lotteryInfoForm.effStartTime){
            callback(new Error('请输入活动开始时间'));
        }
        if (new Date(value).getTime() < new Date(this.lotteryInfoForm.effStartTime).getTime()) {
          callback(new Error('活动结束时间需要大于活动开始时间'));
        } else {
          callback();
        }
      };
      //是否分摊活动验证
      var checkCostAllocationFlag= (rule, value, callback) => {
        if (!value) {
          return callback(new Error('请选择是否分摊'));
        } else{
          if(value == 1){
            var parentAllocationScale = this.lotteryInfoForm.parentAllocationScale;//母平台分摊比例
            var childAllocationScale = this.lotteryInfoForm.childAllocationScale;//子平台分摊比例
            var merchantAllocationScale = this.lotteryInfoForm.merchantAllocationScale;//商家分摊比例
            var storeAllocationScale = this.lotteryInfoForm.storeAllocationScale;//店铺分摊比例
            if(parentAllocationScale == null || parentAllocationScale == '' ) {
              callback(new Error('请输入母平台分摊比例'));
            }else if(childAllocationScale == null || childAllocationScale == '' ) {
              callback(new Error('请输入子平台分摊比例'));
            }else if(merchantAllocationScale == null || merchantAllocationScale == '' ) {
              callback(new Error('请输入商家分摊比例'));
            }else if(storeAllocationScale == null || storeAllocationScale == '' ) {
              callback(new Error('请输入店铺分摊比例'));
            }else if (!Number.isInteger(parentAllocationScale) || !Number.isInteger(childAllocationScale) 
              || !Number.isInteger(merchantAllocationScale)  || !Number.isInteger(storeAllocationScale) ) {
              callback(new Error('请输入数字值'));
            } else {
              if (Number(parentAllocationScale) +  Number(childAllocationScale) 
                + Number(merchantAllocationScale) + Number(storeAllocationScale)!=100 ) {
                callback(new Error('母平台、子平台、商家、店铺分摊比例总和为100'));
              } else {
                callback();
              }
            }
          } else {
            callback();
          }
        }
      };
      //活动规则-无订单抽奖-每次抽奖需消耗验证
      var checkDrawPointsPerTime = (rule, value, callback) => {
        if(this.lotteryInfoForm.lotteryType == 1 ){
          if ( !value ) {
            callback(new Error('请输入每次抽奖所需消耗'));
          } else {
            callback();
          }
        }else{
            callback();
        }
      };
      //活动规则-无订单抽奖-免积分抽奖次数验证
      var checkCostFreeDrawTimes = (rule, value, callback) => {
        if(this.lotteryInfoForm.lotteryType == 1 ){
          if ( !value ) {
            callback(new Error('请输入免积分抽奖次数'));
          } else {
            callback();
          }
        }else{
            callback();
        }
      };
      //活动规则-订单抽奖-单次消费订单金额-每次抽奖需消耗
      var checkDrawTimesPerOrderOne = (rule, value, callback) => {
        if(this.lotteryInfoForm.orderDrawType == 1 ){
          if ( !value ) {
            callback(new Error('请输入每次抽奖所需消耗'));
          } else {
            callback();
          }
        }else{
            callback();
        }
      };
      //活动规则-订单抽奖-消费订单金额每满-每次抽奖需消耗
      var checkDrawTimesPerOrderTwo = (rule, value, callback) => {
        if(this.lotteryInfoForm.orderDrawType == 2 ){
          if ( !value ) {
            callback(new Error('请输入每次抽奖所需消耗'));
          } else {
            callback();
          }
        }else{
            callback();
        }
      };
      //活动规则-订单抽奖-累计消费订单金额-每次抽奖需消耗
      var checkDrawTimesPerOrderThree = (rule, value, callback) => {
        if(this.lotteryInfoForm.orderDrawType == 3 ){
          if ( !value ) {
            callback(new Error('请输入每次抽奖所需消耗'));
          } else {
            callback();
          }
        }else{
            callback();
        }
      };
      return {
        // 活动时间校验
        timeCheck: {
          disabledDate: time => {
            if (this.promotionStartEndTime) {
              return time.getTime() < Date.now() - 8.64e7 || time.getTime() > new Date(this.promotionStartEndTime).getTime()
            } else {
              return time.getTime() < Date.now() - 8.64e7
            }
          }
        },
        lotteryInfoForm:{lotteryType:1,costAllocationFlag:"1",channelIds:[],storeArea:"0",userArea:"0",proUserType:"0",lotteryAwardsList:[],"promotionStartEndTime":[]},//页面model
        awardsLevelList:[{id:1,name:'一等奖'},{id:2,name:'二等奖'},{id:3,name:'三等奖'},{id:4,name:'四等奖'},{id:5,name:'五等奖'},{id:6,name:'六等奖'}],//奖项等级list
        awardsCategoryList:[{id:1,name:'谢谢参与'},{id:2,name:'商品'},{id:3,name:'优惠券'},{id:4,name:'积分'}],//奖项分类list
        tagsList:[{"tagName":"活动标签1","id":1},{"tagName":"活动标签2","id":2},{"tagName":"活动标签3","id":3}],//标签list
        tagCategoryList:[{ "id":1, "categoryName":"标签分类" }],//标签分类list
        addTagDialogFormVisible: false,//标签弹窗Visible
        //标签弹窗Model
        addTagForm:{},
        //标签弹窗验证
        addTagRules:{
            categoryId:[{ required: true, message:"请选择标签分类", trigger: "change"}],
            tagName:[{ required: true, message:"请输入标签名称", trigger: "blur"}], 
        },
        //渠道Tree List
        channelList:[],
        //渠道配置项
        channlProps:{label: 'childName'},
        deptType:localStorage.getItem("deptType"),//当前登录用户所属组织类型
			  formLabelWidth: '120px',
        dialogProductVisible: false, // 商品弹窗控制
        dialogCouponVisible: false, // 优惠券弹窗控制
        tabsIndex:'first',
        formInline:{
          商品类目:"1",
          商品品牌:"1",
          start:1,
          limit:10
        },//商品弹窗 查询参数
        couponformInline:{
          start:1,
          limit:10
        },//优惠券弹窗查询参数
        productListloading:true,//商品loading
        couponListloading:true,//优惠券loading
        markProFlag:'',
        productData:[],
        couponDataList:[],
        dataForm6:{},
        promName: "",
        selectAddProduct:[],//弹窗选择商品
        dynamicValidateForm:{
          domains:[
            
          ],
          dataForm0: {
            awardsLevel: "",
            awardsCategory: 1,
            awardsRefId: "",
            awardsRefNum: "",
            awardsRefId: "",
            awardsRefName: "",
            winningNum: "",
            winningRate: "",
          },
          dataForm1: {
            awardsLevel: "",
            awardsCategory: 1,
            awardsRefId: "",
            awardsRefNum: "",
            awardsRefId: "",
            awardsRefName: "",
            winningNum: "",
            winningRate: "",
          },
          dataForm2: {
            awardsLevel: "",
            awardsCategory: 1,
            awardsRefId: "",
            awardsRefNum: "",
            awardsRefId: "",
            awardsRefName: "",
            winningNum: "",
            winningRate: "",
          },
          dataForm3: {
            awardsLevel: "",
            awardsCategory: 1,
            awardsRefId: "",
            awardsRefNum: "",
            awardsRefId: "",
            awardsRefName: "",
            winningNum: "",
            winningRate: "",
          },
          dataForm4: {
            awardsLevel: "",
            awardsCategory: 1,
            awardsRefId: "",
            awardsRefNum: "",
            coupon4: "",
            awardsRefName: "",
            winningNum: "",
            winningRate: "",
          },
          dataForm5: {
            awardsLevel: "",
            awardsCategory: 1,
            awardsRefId: "",
            awardsRefNum: "",
            awardsRefId: "",
            awardsRefName: "",
            winningNum: "",
            winningRate: "",
          },
        },//总的大表单
        dataForm7:{},
        editDialogVisible: false,
        editDialogVisible2: false,
        editorOption: {},
        size: "small",
        uploadVisible: false,
        operation: false, // true:商品导入, false:下载模板
        activeName: 0,
        setUp: false,
        search: false,
        active: 1,
        //设置抽奖规则验证
        lotteryInfoFormRules:{
          activityName: [
            { required: true, message: '请输入活动名称', trigger: 'blur' },
            { min: 3, max: 60, message: '长度在 3 到 60 个字符', trigger: 'blur' }
          ],
          // effStartTime: [{ required: true, message: '请输入活动开始时间', trigger: 'change' }],
          // effEndTime: [
          //   { required: true, message: '请输入活动结束时间', trigger: 'change' },
          //   { validator: checkEffEndTime, trigger: 'change' }
          // ],
          promotionStartEndTime:[{ required: true, message: '请选择时间', trigger: 'blur' },],
          lotteryTemplate: [{ required: true, message: '请选择抽奖模板', trigger: 'change' }],
          costAllocationFlag: [{ required: true,  validator: checkCostAllocationFlag, trigger: 'change' }],
          // labelId: [{ required: true, message: '请选择活动标签', trigger: 'change' }],
          proUserType:[{required: true, message: "请选择用户类型", trigger: "change"}],
          // channelIds:[{required: true, message: "请选择使用渠道", trigger: "checked"}],
          storeArea:[{required: true, message: "请选择店铺地址", trigger: "change"}],
          userArea:[{required: true, message: "请选择商家地址", trigger: "change"}],
          drawPointsPerTime: [{required: true, validator: checkDrawPointsPerTime, trigger: 'blur' }],
          costFreeDrawTimes: [{required: true, validator: checkCostFreeDrawTimes, trigger: 'blur' }],
          drawTimesPerOrderOne: [{required: true, validator: checkDrawTimesPerOrderOne, trigger: 'blur' }],
          drawTimesPerOrderTwo: [{required: true, validator: checkDrawTimesPerOrderTwo, trigger: 'blur' }],
          drawTimesPerOrderThree: [{ validator: checkDrawTimesPerOrderThree, trigger: 'blur' }],
          dailyDrawTimesLimit: [{ required: true, message: '请输入用户每日抽奖次数上限', trigger: 'blur' }],
          dailyWinningTimesLimit: [{ required: true, message: '请输入用户每日中奖次数上限', trigger: 'blur' }],
        },
        dataForm0Rules:{
          awardsLevel: [{ required: false, message: '请选择奖项等级', trigger: 'change' }],
          winningRate: [{ required: false, message: '请选择奖项等级', trigger: 'blur' }],
        },
        dataForm1Rules:{
          awardsLevel: [{ required: true, message: '请选择奖项等级', trigger: 'change' }],
        },
        dataForm2Rules:{
          awardsLevel: [{ required: true, message: '请选择奖项等级', trigger: 'change' }],
        },
        dataForm3Rules:{
          awardsLevel: [{ required: true, message: '请选择奖项等级', trigger: 'change' }],
        },
        dataForm4Rules:{
          awardsLevel: [{ required: true, message: '请选择奖项等级', trigger: 'change' }],
        },
        dataForm5Rules:{
          awardsLevel: [{ required: true, message: '请选择奖项等级', trigger: 'change' }],
        },
        verifyDialogFormVisible:false,//审核弹窗
        verifyForm:{},
        id: this.$route.params.id,
        status:0,
        templateDialogFormVisible:false,//模板弹窗
        templateForm:{},//模板model
        showNewAddDialog: false,              // 是否显示新增form
        addButtonDisabled: false,             // 新增form表单按钮是都禁用（到达10个表单的时候禁止新增）
      };
    },

    methods: {
      //获取子平台列表
      getChildList(){
        let channel = {childName:"卡奥斯运营平台",id:"179"};
        var that = this;
        this.utils.request.queryChildList({},res=>{
          if(res.code == '0000' && res.data && res.data.length > 0){
            channel.children = res.data;
            that.channelList.push(channel);
            if(that.promotionId == null){
              that.$nextTick(() => {
                that.$refs.channelTree.setChecked('179',true,false)
                res.data.forEach(item =>{
                  that.$refs.channelTree.setChecked(item.id,true,false)
                });
              });
            }
          }
        })
      },
      /**
       * 修改是否分摊
       */
      costAllocationFlagFun(val){
        console.log(val);
        if(val == 2){
          this.lotteryInfoFormRules.costAllocationFlag[0].required = false;
          console.log(this.lotteryInfoFormRules.costAllocationFlag);
        }else{
          this.lotteryInfoFormRules.costAllocationFlag[0].required = true;
          console.log(this.lotteryInfoFormRules.costAllocationFlag);
        }
      },
      //查询标签List
      queryTagList(id){
          let that = this;
          this.utils.request.getTagList({},res=>{
              this.tagsList = res.data.rows;
              if(that.id!=0){
                that.getLotteryThemeInfo();
              }
              if(id != null){
                  this.lotteryInfoForm.labelId = id;
              }
          })
      },
      //标签分类查询
      getTagCategoryList(){
          let that = this;
          this.utils.request.getTagCategoryList({},res=>{
              this.tagCategoryList = res.data.rows;
          })
      },
      //新增标签弹窗
      addtags(){
          if(this.$refs["addTagForm"] != undefined){
              this.$refs["addTagForm"].resetFields();
          }
          this.addTagDialogFormVisible = true;
      },
      //新增标签
      addNewTag(){
        this.$refs["addTagForm"].validate((valid) => {
            if (valid) {
                //TODO 新增标签
                // this.addTagForm
                let that = this;
                this.utils.request.addTag(this.addTagForm,res=>{
                    that.queryTagList(res.data);
                    that.addTagDialogFormVisible = false;
                    that.getTagCategoryList();
                })

            } else {
                console.log('error submit!!');
                return false;
            }
        });
      },
      //下一步
      next() {
        var flag = true;
        console.log(this.lotteryInfoForm.id);
        //设置抽奖规则验证
        if (this.active === 1) {
          console.log(this.$refs['lotteryInfoForm']);
          this.$refs['lotteryInfoForm'].validate((valid) => {
            if (valid) {
              let that = this;
              //处理数据 根据订单抽奖类型 取不同的值
              if(this.lotteryInfoForm.lotteryType==2&&this.lotteryInfoForm.orderDrawType==1){
                  this.lotteryInfoForm.orderDrawAmount = this.lotteryInfoForm.orderDrawAmountOne;
                  this.lotteryInfoForm.drawTimesPerOrder = this.lotteryInfoForm.drawTimesPerOrderOne;
              }else if(this.lotteryInfoForm.lotteryType==2&&this.lotteryInfoForm.orderDrawType==2){
                  this.lotteryInfoForm.orderDrawAmount = this.lotteryInfoForm.orderDrawAmountTwo;
                  this.lotteryInfoForm.drawTimesPerOrder = this.lotteryInfoForm.drawTimesPerOrderTwo;
              }else if(this.lotteryInfoForm.lotteryType==2&&this.lotteryInfoForm.orderDrawType==3){
                  this.lotteryInfoForm.orderDrawAmount = this.lotteryInfoForm.orderDrawAmountThree;
                  this.lotteryInfoForm.drawTimesPerOrder = this.lotteryInfoForm.drawTimesPerOrderThree;
              }
              //当前登录用户身份为母平台校验所属渠道
              if(this.deptType == 0){
                if(this.$refs.channelTree.getCheckedKeys().length <=0 ){
                  this.$message({"message":"请选择使用渠道"})
                  loading.close();
                  return false;
                }else{
                  this.lotteryInfoForm.channelCodes = this.$refs.channelTree.getCheckedKeys().join(",");
                }         
              }
              this.lotteryInfoForm.effStartTime = this.lotteryInfoForm.promotionStartEndTime[0];
              this.lotteryInfoForm.effEndTime = this.lotteryInfoForm.promotionStartEndTime[1];
              console.log(this.lotteryInfoForm);
              if(this.id!=0){
                this.lotteryInfoForm.id = this.id;
                this.utils.request.updateLotteryActivity(this.lotteryInfoForm,res=>{
                  if (res.code == "0000") {
                    // that.lotteryInfoForm.id = res.data;
                    flag = true;
                  } else {
                    flag = false;
                    that.$message({
                      message: "操作失败, " + res.msg,
                      type: "error"
                    });
                  }
                })
              }else{
                this.utils.request.saveLotteryActivity(this.lotteryInfoForm,res=>{
                  if (res.code == "0000") {
                    that.lotteryInfoForm.id = res.data;
                    that.id = res.data;
                    that.status=1;
                    flag = true;
                  } else {
                    flag = false;
                    that.$message({
                      message: "操作失败, " + res.msg,
                      type: "error"
                    });
                  }
                })
              }
            } else {
              flag = false;
              console.log('error submit!!');
              return false;
            }
          });
        }
        //奖品设置
        if(this.active === 2){
          var that = this;
          console.log(this.$refs['dynamicValidateForm.dataForm0']);
          const r = /^\+?[1-9][0-9]*$/;  // 正整数正则
          if(this.dynamicValidateForm.dataForm0.awardsLevel == null || this.dynamicValidateForm.dataForm0.awardsLevel == ''){
            that.$message({message: "请选择奖项等级",type: "error"});  
            flag = false; 
            return false;
          }
          //商品 积分 优惠券
          if(this.dynamicValidateForm.dataForm0.awardsCategory == 2 || this.dynamicValidateForm.dataForm0.awardsCategory == 3 || this.dynamicValidateForm.dataForm0.awardsCategory == 4){
            if(this.dynamicValidateForm.dataForm0.awardsCategory == 2 || this.dynamicValidateForm.dataForm0.awardsCategory == 3){
              if(this.dynamicValidateForm.dataForm0.awardsRefId == null || this.dynamicValidateForm.dataForm0.awardsRefId == ''){
                that.$message({message: "请添加商品或优惠券",type: "error"}); 
                flag = false;  
                return false;
              }
              if(this.dynamicValidateForm.dataForm0.awardsRefName == null || this.dynamicValidateForm.dataForm0.awardsRefName == ''){
                that.$message({message: "奖项名称不能为空",type: "error"}); 
                flag = false;  
                return false;
              }
            }
            //奖品数量
            if(this.dynamicValidateForm.dataForm0.winningNum == null || this.dynamicValidateForm.dataForm0.winningNum == ''){
              that.$message({message: "奖品数量不能为空",type: "error"});   
              flag = false; 
              return false;

            }
            if (!r.test(this.dynamicValidateForm.dataForm0.winningNum)) { 
              that.$message({message: "奖品数量必须为正整数",type: "error"});   
              flag = false; 
              return false;
            } 
          }
          //积分
          if(this.dynamicValidateForm.dataForm0.awardsCategory == 4 ){
            if(this.dynamicValidateForm.dataForm0.awardsRefNum == null || this.dynamicValidateForm.dataForm0.awardsRefNum == ''){
              that.$message({message: "积分不能为空",type: "error"});  
              flag = false; 
              return false;
            }
            if (!r.test(this.dynamicValidateForm.dataForm0.awardsRefNum)) { 
              that.$message({message: "积分值必须为正整数",type: "error"});   
              flag = false; 
              return false;
            } 
          }
          //中奖率
          if(this.dynamicValidateForm.dataForm0.winningRate == null || this.dynamicValidateForm.dataForm0.winningRate == ''){
            that.$message({message: "中奖率不能为空",type: "error"}); 
            flag = false; 
            return false;
          }
          //中奖率
          if (!r.test(this.dynamicValidateForm.dataForm0.winningRate)) {
            that.$message({message: "中奖率必须为正整数",type: "error"}); 
            flag = false;
            return false;
          }
//-----------------------------奖项二-----------------------------------
          if(this.dynamicValidateForm.dataForm1.awardsLevel == null || this.dynamicValidateForm.dataForm1.awardsLevel == ''){
            that.$message({message: "请选择奖项等级",type: "error"});  
            flag = false; 
            return false;
          }
          //商品 积分 优惠券
          if(this.dynamicValidateForm.dataForm1.awardsCategory == 2 || this.dynamicValidateForm.dataForm1.awardsCategory == 3 || this.dynamicValidateForm.dataForm1.awardsCategory == 4){
            if(this.dynamicValidateForm.dataForm1.awardsCategory == 2 || this.dynamicValidateForm.dataForm1.awardsCategory == 3){
              if(this.dynamicValidateForm.dataForm1.awardsRefId == null || this.dynamicValidateForm.dataForm1.awardsRefId == ''){
                that.$message({message: "请添加商品或优惠券",type: "error"}); 
                flag = false;  
                return false;
              }
            }
            if(this.dynamicValidateForm.dataForm1.awardsRefName == null || this.dynamicValidateForm.dataForm1.awardsRefName == ''){
              that.$message({message: "奖项名称不能为空",type: "error"}); 
              flag = false;  
              return false;
            }
            //奖品数量
            if(this.dynamicValidateForm.dataForm1.winningNum == null || this.dynamicValidateForm.dataForm1.winningNum == ''){
              that.$message({message: "奖品数量不能为空",type: "error"});   
              flag = false; 
              return false;

            }
            if (!r.test(this.dynamicValidateForm.dataForm1.winningNum)) { 
              that.$message({message: "奖品数量必须为正整数",type: "error"});   
              flag = false; 
              return false;
            } 
          }
          //积分
          if(this.dynamicValidateForm.dataForm1.awardsCategory == 4 ){
            if(this.dynamicValidateForm.dataForm1.awardsRefNum == null || this.dynamicValidateForm.dataForm1.awardsRefNum == ''){
              that.$message({message: "积分不能为空",type: "error"});  
              flag = false; 
              return false;
            }
            if (!r.test(this.dynamicValidateForm.dataForm1.awardsRefNum)) { 
              that.$message({message: "积分值必须为正整数",type: "error"});   
              flag = false; 
              return false;
            } 
          }
          //中奖率
          if(this.dynamicValidateForm.dataForm1.winningRate == null || this.dynamicValidateForm.dataForm1.winningRate == ''){
            that.$message({message: "中奖率不能为空",type: "error"}); 
            flag = false; 
            return false;
          }
          //中奖率
          if (!r.test(this.dynamicValidateForm.dataForm1.winningRate)) {
            that.$message({message: "中奖率必须为正整数",type: "error"}); 
            flag = false;
            return false;
          }
          
//-----------------------------奖项三-----------------------------------
          if(this.dynamicValidateForm.dataForm2.awardsLevel == null || this.dynamicValidateForm.dataForm2.awardsLevel == ''){
            that.$message({message: "请选择奖项等级",type: "error"});  
            flag = false; 
            return false;
          }
          //商品 积分 优惠券
          if(this.dynamicValidateForm.dataForm2.awardsCategory == 2 || this.dynamicValidateForm.dataForm2.awardsCategory == 3 || this.dynamicValidateForm.dataForm2.awardsCategory == 4){
            if(this.dynamicValidateForm.dataForm2.awardsCategory == 2 || this.dynamicValidateForm.dataForm2.awardsCategory == 3){
              if(this.dynamicValidateForm.dataForm2.awardsRefId == null || this.dynamicValidateForm.dataForm2.awardsRefId == ''){
                that.$message({message: "请添加商品或优惠券",type: "error"}); 
                flag = false;  
                return false;
              }
            }
            if(this.dynamicValidateForm.dataForm2.awardsRefName == null || this.dynamicValidateForm.dataForm2.awardsRefName == ''){
              that.$message({message: "奖项名称不能为空",type: "error"}); 
              flag = false;  
              return false;
            }
            //奖品数量
            if(this.dynamicValidateForm.dataForm2.winningNum == null || this.dynamicValidateForm.dataForm2.winningNum == ''){
              that.$message({message: "奖品数量不能为空",type: "error"});   
              flag = false; 
              return false;

            }
            if (!r.test(this.dynamicValidateForm.dataForm2.winningNum)) { 
              that.$message({message: "奖品数量必须为正整数",type: "error"});   
              flag = false; 
              return false;
            } 
          }
          //积分
          if(this.dynamicValidateForm.dataForm2.awardsCategory == 4 ){
            if(this.dynamicValidateForm.dataForm2.awardsRefNum == null || this.dynamicValidateForm.dataForm2.awardsRefNum == ''){
              that.$message({message: "积分不能为空",type: "error"});  
              flag = false; 
            return false;
            }
            if (!r.test(this.dynamicValidateForm.dataForm2.awardsRefNum)) { 
              that.$message({message: "积分值必须为正整数",type: "error"});   
              flag = false; 
              return false;
            } 
          }
          //中奖率
          if(this.dynamicValidateForm.dataForm2.winningRate == null || this.dynamicValidateForm.dataForm2.winningRate == ''){
            that.$message({message: "中奖率不能为空",type: "error"}); 
            flag = false; 
            return false;
          }
          //中奖率
          if (!r.test(this.dynamicValidateForm.dataForm2.winningRate)) {
            that.$message({message: "中奖率必须为正整数",type: "error"}); 
            flag = false;
            return false;
          }
          
//-----------------------------奖项四-----------------------------------
          if(this.dynamicValidateForm.dataForm3.awardsLevel == null || this.dynamicValidateForm.dataForm3.awardsLevel == ''){
            that.$message({message: "请选择奖项等级",type: "error"});  
            flag = false; 
            return false;
          }
          //商品 积分 优惠券
          if(this.dynamicValidateForm.dataForm3.awardsCategory == 2 || this.dynamicValidateForm.dataForm3.awardsCategory == 3 || this.dynamicValidateForm.dataForm3.awardsCategory == 4){
            if(this.dynamicValidateForm.dataForm3.awardsCategory == 2 || this.dynamicValidateForm.dataForm3.awardsCategory == 3){
              if(this.dynamicValidateForm.dataForm3.awardsRefId == null || this.dynamicValidateForm.dataForm3.awardsRefId == ''){
                that.$message({message: "请添加商品或优惠券",type: "error"}); 
                flag = false;  
                return false;
              }
            }
            if(this.dynamicValidateForm.dataForm3.awardsRefName == null || this.dynamicValidateForm.dataForm3.awardsRefName == ''){
              that.$message({message: "奖项名称不能为空",type: "error"}); 
              flag = false;  
              return false;
            }
            //奖品数量
            if(this.dynamicValidateForm.dataForm3.winningNum == null || this.dynamicValidateForm.dataForm3.winningNum == ''){
              that.$message({message: "奖品数量不能为空",type: "error"});   
              flag = false; 
              return false;

            }
            if (!r.test(this.dynamicValidateForm.dataForm3.winningNum)) { 
              that.$message({message: "奖品数量必须为正整数",type: "error"});   
              flag = false; 
              return false;
            } 
          }
          //积分
          if(this.dynamicValidateForm.dataForm3.awardsCategory == 4 ){
            if(this.dynamicValidateForm.dataForm3.awardsRefNum == null || this.dynamicValidateForm.dataForm3.awardsRefNum == ''){
              that.$message({message: "积分不能为空",type: "error"});  
              flag = false; 
              return false;
            }
            if (!r.test(this.dynamicValidateForm.dataForm3.awardsRefNum)) { 
              that.$message({message: "积分值必须为正整数",type: "error"});   
              flag = false; 
              return false;
            } 
          }
          //中奖率
          if(this.dynamicValidateForm.dataForm3.winningRate == null || this.dynamicValidateForm.dataForm3.winningRate == ''){
            that.$message({message: "中奖率不能为空",type: "error"}); 
            flag = false; 
            return false;
          }
          //中奖率
          if (!r.test(this.dynamicValidateForm.dataForm3.winningRate)) {
            that.$message({message: "中奖率必须为正整数",type: "error"}); 
            flag = false;
            return false;
          }
          
//-----------------------------奖项五-----------------------------------
          if(this.dynamicValidateForm.dataForm4.awardsLevel == null || this.dynamicValidateForm.dataForm4.awardsLevel == ''){
            that.$message({message: "请选择奖项等级",type: "error"});  
            flag = false; 
            return false;
          }
          //商品 积分 优惠券
          if(this.dynamicValidateForm.dataForm4.awardsCategory == 2 || this.dynamicValidateForm.dataForm4.awardsCategory == 3 || this.dynamicValidateForm.dataForm4.awardsCategory == 4){
            if(this.dynamicValidateForm.dataForm4.awardsCategory == 2 || this.dynamicValidateForm.dataForm4.awardsCategory == 3){
              if(this.dynamicValidateForm.dataForm4.awardsRefId == null || this.dynamicValidateForm.dataForm4.awardsRefId == ''){
                that.$message({message: "请添加商品或优惠券",type: "error"}); 
                flag = false;  
                return false;
              }
            }
            if(this.dynamicValidateForm.dataForm4.awardsRefName == null || this.dynamicValidateForm.dataForm4.awardsRefName == ''){
              that.$message({message: "奖项名称不能为空",type: "error"}); 
              flag = false;  
              return false;
            }
            //奖品数量
            if(this.dynamicValidateForm.dataForm4.winningNum == null || this.dynamicValidateForm.dataForm4.winningNum == ''){
              that.$message({message: "奖品数量不能为空",type: "error"});   
              flag = false; 
              return false;

            }
            if (!r.test(this.dynamicValidateForm.dataForm4.winningNum)) { 
              that.$message({message: "奖品数量必须为正整数",type: "error"});   
              flag = false; 
              return false;
            } 
          }
          //积分
          if(this.dynamicValidateForm.dataForm4.awardsCategory == 4 ){
            if(this.dynamicValidateForm.dataForm4.awardsRefNum == null || this.dynamicValidateForm.dataForm4.awardsRefNum == ''){
              that.$message({message: "积分不能为空",type: "error"});  
              flag = false; 
              return false;
            }
            if (!r.test(this.dynamicValidateForm.dataForm4.awardsRefNum)) { 
              that.$message({message: "积分值必须为正整数",type: "error"});   
              flag = false; 
              return false;
            } 
          }
          //中奖率
          if(this.dynamicValidateForm.dataForm4.winningRate == null || this.dynamicValidateForm.dataForm4.winningRate == ''){
            that.$message({message: "中奖率不能为空",type: "error"}); 
            flag = false; 
            return false;
          }
          //中奖率
          if (!r.test(this.dynamicValidateForm.dataForm4.winningRate)) {
            that.$message({message: "中奖率必须为正整数",type: "error"}); 
            flag = false;
            return false;
          }
          
//-----------------------------奖项六-----------------------------------
          if(this.dynamicValidateForm.dataForm5.awardsLevel == null || this.dynamicValidateForm.dataForm5.awardsLevel == ''){
            that.$message({message: "请选择奖项等级",type: "error"});  
            flag = false; 
            return false;
          }
          //商品 积分 优惠券
          if(this.dynamicValidateForm.dataForm5.awardsCategory == 2 || this.dynamicValidateForm.dataForm5.awardsCategory == 3 || this.dynamicValidateForm.dataForm5.awardsCategory == 4){
            if(this.dynamicValidateForm.dataForm5.awardsCategory == 2 || this.dynamicValidateForm.dataForm5.awardsCategory == 3){
              if(this.dynamicValidateForm.dataForm5.awardsRefId == null || this.dynamicValidateForm.dataForm5.awardsRefId == ''){
                that.$message({message: "请添加商品或优惠券",type: "error"}); 
                flag = false;  
                return false;
              }
            }
            if(this.dynamicValidateForm.dataForm5.awardsRefName == null || this.dynamicValidateForm.dataForm5.awardsRefName == ''){
              that.$message({message: "奖项名称不能为空",type: "error"}); 
              flag = false;
              return false;  
            }
            //奖品数量
            if(this.dynamicValidateForm.dataForm5.winningNum == null || this.dynamicValidateForm.dataForm5.winningNum == ''){
              that.$message({message: "奖品数量不能为空",type: "error"});   
              flag = false; 
              return false;

            }
            if (!r.test(this.dynamicValidateForm.dataForm5.winningNum)) { 
              that.$message({message: "奖品数量必须为正整数",type: "error"});   
              flag = false; 
              return false;
            } 
          }
          //积分
          if(this.dynamicValidateForm.dataForm5.awardsCategory == 4 ){
            if(this.dynamicValidateForm.dataForm5.awardsRefNum == null || this.dynamicValidateForm.dataForm5.awardsRefNum == ''){
              that.$message({message: "积分不能为空",type: "error"});  
              flag = false; 
              return false;
            }
            if (!r.test(this.dynamicValidateForm.dataForm5.awardsRefNum)) { 
              that.$message({message: "积分值必须为正整数",type: "error"});   
              flag = false; 
              return false;
            } 
          }
          //中奖率
          if(this.dynamicValidateForm.dataForm5.winningRate == null || this.dynamicValidateForm.dataForm5.winningRate == ''){
            that.$message({message: "中奖率不能为空",type: "error"}); 
            flag = false; 
            return false;
          }
          //中奖率
          if (!r.test(this.dynamicValidateForm.dataForm5.winningRate)) {
            that.$message({message: "中奖率必须为正整数",type: "error"}); 
            flag = false;
            return false;
          }
          var ary = new Array();
          ary.push(this.dynamicValidateForm.dataForm0.awardsLevel);
          ary.push(this.dynamicValidateForm.dataForm1.awardsLevel);
          ary.push(this.dynamicValidateForm.dataForm2.awardsLevel);
          ary.push(this.dynamicValidateForm.dataForm3.awardsLevel);
          ary.push(this.dynamicValidateForm.dataForm4.awardsLevel);
          ary.push(this.dynamicValidateForm.dataForm5.awardsLevel);
          var s = ary.join(",") + ",";
          var awardsLevelFlag = false;
          for (var i = 0; i < ary.length; i++) {
              if (s.replace(ary[i] + ",", "").indexOf(ary[i] + ",") > -1) {
                  awardsLevelFlag = true;
                  that.$message({message: "奖项等级不能重复",type: "error"}); 
                  break;
              }
          }
          if(awardsLevelFlag){return}
          var numbers = Number(this.dynamicValidateForm.dataForm0.winningRate)+Number(this.dynamicValidateForm.dataForm1.winningRate)+
                        Number(this.dynamicValidateForm.dataForm2.winningRate)+
                        Number(this.dynamicValidateForm.dataForm3.winningRate)+
                        Number(this.dynamicValidateForm.dataForm4.winningRate)+
                        Number(this.dynamicValidateForm.dataForm5.winningRate);
          if(numbers!=100){
            that.$message({message: "中奖率之和不能大于100%",type: "error"}); 
            return false;
          }
          if(this.dataForm7.notWinningDesc == null || this.dataForm7.notWinningDesc == ''){
            that.$message({message: "未中奖说明不能为空",type: "error"}); 
            return false;
          }
          //表单验证后提交数据
          if(flag){
            var arry = [];
            arry.push(this.dynamicValidateForm.dataForm0);
            arry.push(this.dynamicValidateForm.dataForm1);
            arry.push(this.dynamicValidateForm.dataForm2);
            arry.push(this.dynamicValidateForm.dataForm3);
            arry.push(this.dynamicValidateForm.dataForm4);
            arry.push(this.dynamicValidateForm.dataForm5);
            var param = {};
            param.lotteryAwardsList = arry;
            param.themeRefId = this.lotteryInfoForm.id;
            param.notWinningDesc = this.dataForm7.notWinningDesc;
            if(this.id!=0&&this.lotteryInfoForm.lotteryAwardsList.length!=0){
              this.utils.request.updateLotteryAwards(param,res=>{
                if (res.code == "0000") {
                  that.lotteryInfoForm.status = res.data;
                  flag = true;
                } else {
                  flag = false;
                  that.$message({
                    message: "操作失败, " + res.msg,
                    type: "error"
                  });
                }
              })

            }else{
              this.utils.request.saveLotteryAwards(param,res=>{
                if (res.code == "0000") {
                  that.lotteryInfoForm.status = res.data;
                  flag = true;
                } else {
                  flag = false;
                  that.$message({
                    message: "操作失败, " + res.msg,
                    type: "error"
                  });
                }
              })
            }
          }
        }
        if (this.active == 3) {
          this.$message({ message: "操作成功,请等待审核", type: "success" });
          return;
        }
        if(flag){
          if (this.active++ > 3) this.active = 1;
        }
      },
      //上一步
      upStep() {
        if (this.active === 2) {this.active = 1;}
      },
      //返回抽奖列表
      viewList(){
          this.$router.push({ path:'/pages/promotionManagement/lotteryRule'})
      },
      //提交审核
      submitReview:function(data){
        let that = this;
        this.utils.request.closeLotteryActivity({id:that.id,"status":2},res=>{
          that.status=2;
          that.$message({ message: "提交审核成功", type: "success" });
        })
      },
      //审核
      review:function(data){
        this.verifyDialogFormVisible =  true;
        this.verifyForm.id = this.id;
      },
      //审核
      reviewDialog:function(data){
        if(this.verifyForm.checkRemark==null||this.verifyForm.checkRemark==''){
          this.$message({ message: "审核意见不能为空", type: "error" });
          return false;
        }
        let that = this;
        this.verifyForm.verifyStatus = data;
        that.utils.request.verifyLotteryActivity(this.verifyForm,res=>{
          if(res.code == "0000"){
            that.verifyDialogFormVisible =  false;
            that.status=0;
            that.$message({ message: "审核完成", type: "success" });
          }else{
            that.$message({ message: "审核失败", type: "error" });
          }
        })
      },
      //保存为模板
      saveLotteryTemplate(){
        var that = this;
        this.templateForm.id = this.id;
        if(this.templateForm.templateName == null || this.templateForm.templateName == ''){
            that.$message({ message: "模板名称不能为空", type: "error" });
            return false;
        }
        this.utils.request.saveLotteryTemplate(this.templateForm,res=>{
          if(res.code == "0000"){
            that.templateDialogFormVisible =  false;
            that.$message({ message: "模板保存完成", type: "success" });
          }else{
            that.$message({ message: "模板保存失败,"+res.msg, type: "error" });
          }
        })
      },
      
      // 新增表单
      addDomain() {
        this.showNewAddDialog = true;
        let formList = this.dynamicValidateForm.domains;
        formList.push({
          id: Number(formList.length) + 6,//新增的每一个表单的id 
              //新增的每一个表单中的输入框等表单元素的数据
              form:{
                 value: "",
                 awardsCategory: 1,
                 awardsRefId: "",
                 awardsRefNum: "",
                 awardsRefId: "",
                 awardsRefName: "",
                 winningNum: "",
                 winningRate: "",
              }
        });

        // 添加到4个后禁用新增按钮 最多显示10个表单
        if( formList.length == 4) {
          this.addButtonDisabled = true;
        }

        // 往选项里面追加数据  保持form表单数和奖项一样
        let awardsLevelList = this.awardsLevelList;
        let tips = '';
        if(awardsLevelList.length == 6) {
          tips = '七等奖'
        }
        if(awardsLevelList.length == 7) {
          tips = '八等奖'
        }
        if(awardsLevelList.length == 8) {
          tips = '九等奖'
        }
        if(awardsLevelList.length == 9) {
          tips = '十等奖'
        }

        awardsLevelList.push({
          id: Number(awardsLevelList.length)+1,
          name: tips
        })
      },

      //删除新增表单
      removeDomain(item) {
        var index = this.dynamicValidateForm.domains.indexOf(item)
        if (index !== -1) {
          this.dynamicValidateForm.domains.splice(index, 1)
        }

        // 判断新增表单个数 是否禁用新增按钮
        if(this.dynamicValidateForm.domains.length < 4) {
          this.addButtonDisabled = false
        }

        // 删除奖项里的数据  保持和form数量一致
        this.awardsLevelList.pop();

      },
      //添加优惠券弹窗
      couponClick(flag) {
        this.markProFlag = flag;
        this.queryPageCouponList();
        this.dialogCouponVisible = true;
      },
      //重置
      resetForm() {
        this.promName = '';
        this.queryPageCouponList();
      },
      // 查询优惠券列表
      queryPageCouponList(){
        let that = this;
        this.couponListloading = true;
        this.couponformInline.promName = this.promName;
        this.couponformInline.grantType = 33;
        this.utils.request.couponQueryConfigPage(this.couponformInline,res=>{
          console.log(res);
          that.couponListloading = false;
          if(res.code == '0000'){
              that.couponDataList = res.data.rows;
              that.couponDataListTotal = res.data.total;
          }
        })  
      },
      //查询优惠券弹窗
      selectCoupon(row,flag){
        console.log(flag);
        this.dynamicValidateForm['dataForm'+flag].awardsRefId = row.id;
        this.dynamicValidateForm["dataForm"+flag].awardsRefName = row.promName;
        console.log(this.dynamicValidateForm["dataForm"+flag].awardsRefName);
        console.log(this.dynamicValidateForm.dataForm0.awardsRefName);
        this.dialogCouponVisible = !this.dialogCouponVisible;	
      },
      //优惠券条数刷新
      couponHandleSizeChange(val){
        this.couponformInline.start = val;
        this.queryPageCouponList();
      },
      //优惠券换页刷新
      couponHandleCurrentChange(val){
          this.couponformInline.start = val;
          this.queryPageCouponList();
      },
      //添加商品弹窗
      productClick(flag) {
        this.markProFlag = flag;
			  this.queryPageProductManagement();
        this.dialogProductVisible = true;
      },
      restForm(){
        this.formInline.code = "";
        this.formInline.goodsName = "";
        this.queryPageProductManagement();
      },
      // 查询商品列表
      queryPageProductManagement(){
        let that = this;
        this.productListloading = true;
        this.utils.request.goodsQuerySkuPage(this.formInline,res=>{
          console.log(res);
          that.productListloading = false;
          if(res.code == '0000'){
              that.productData = res.data.rows;
              that.productListTotal = res.data.total;
          }
        })  
      },
      /**
       * 商品条数刷新
       */
      producthandleSizeChange(val){
        this.formInline.start = val;
        this.queryPageProductManagement();
      },
      /**
       * 商品换页刷新
       */
      producthandleCurrentChange(val){
          this.formInline.start = val;
          this.queryPageProductManagement();
      },
      //选择商品
      selectProduct(row,flag){
        console.log(flag);
        this.dynamicValidateForm['dataForm'+flag].awardsRefId = row.id;
        this.dynamicValidateForm["dataForm"+flag].awardsRefName = row.goodsName;
        console.log(this.dynamicValidateForm["dataForm"+flag].awardsRefName);
        console.log(this.dynamicValidateForm.dataForm0.awardsRefName);
        this.dialogProductVisible = !this.dialogProductVisible;	
      },

//---------------------------------------------------//
      getLotteryThemeInfo(){
        let params = {};
        params.id = this.id;
        var that = this;
        this.utils.request.getLotteryThemeInfo(params,res=>{
          if (res.code == "0000") {
            // that.lotteryInfoForm = res.data;
            for(var key in res.data){
              that.$set(that.lotteryInfoForm,key,res.data[key])
            }
            //回显使用渠道
            if(that.deptType == 0 && res.data.channelCodes != null &&  res.data.channelCodes.length > 0){
                var arry = res.data.channelCodes.split(",");
                that.$set(that.lotteryInfoForm,"channelCodes",res.data["channelCodes"]);
                that.$refs.channelTree.setCheckedKeys(arry);
            }
            
            that.$set(that.lotteryInfoForm,"promotionStartEndTime",[new Date(res.data["effStartTime"]),new Date(res.data["effEndTime"])]);
            that.lotteryInfoForm.proUserType = res.data.proUserType+"";
            that.lotteryInfoForm.channelIds=[];
            that.dataForm7.notWinningDesc = res.data.notWinningDesc;
            that.status = res.data.status;
            if(that.lotteryInfoForm.lotteryType==2&&that.lotteryInfoForm.orderDrawType==1){
              that.lotteryInfoForm.orderDrawAmountOne = that.lotteryInfoForm.orderDrawAmount;
              that.lotteryInfoForm.drawTimesPerOrderOne = that.lotteryInfoForm.drawTimesPerOrder;
            }
            if(that.lotteryInfoForm.lotteryType==2&&that.lotteryInfoForm.orderDrawType==2){
              that.lotteryInfoForm.orderDrawAmountTwo = that.lotteryInfoForm.orderDrawAmount;
              that.lotteryInfoForm.drawTimesPerOrderTwo = that.lotteryInfoForm.drawTimesPerOrder;
            }
            if(that.lotteryInfoForm.lotteryType==2&&that.lotteryInfoForm.orderDrawType==3){
              that.lotteryInfoForm.orderDrawAmountThree = that.lotteryInfoForm.orderDrawAmount;
              that.lotteryInfoForm.drawTimesPerOrderThree = that.lotteryInfoForm.drawTimesPerOrder;
            }
            for(var i = 0; i < res.data.lotteryAwardsList.length;i++){
              
              that.dynamicValidateForm['dataForm'+i]=res.data.lotteryAwardsList[i];
            }
          }else if(res.code == "9999"){
            that.$message({message: res.msg,type: "error"});
          }
        })
      },

//---------------------------------------------------//
      //table的双色条纹
      tableRowClassName({row, rowIndex}) {
          if (rowIndex === 1) {
              return 'warning-row';
          } else if (rowIndex === 3) {
              return 'success-row';
          }
          return '';
      },
      //修改table header的背景色
      tableHeaderColor({ row, column, rowIndex, columnIndex }) {
          if (rowIndex === 0) {
              return 'background-color:rgb(250,250,250);'
          }
      },
    },
    mounted(){
        this.queryTagList();
        this.getTagCategoryList();
        //当前登录用户身份为母平台才获取子平台列表
        if(this.deptType == 0){
          this.getChildList();
        }
    },
    watch:{
      lotteryInfoForm:{
        costAllocationFlag(val){
          console.log(val)
        }
      }
    }

  };
</script>

<style scoped lang="scss">
  // @import '../../../assets/css/public.scss';
  /* 新增form表单按钮样式 */ 
  .add-wrap {
    margin-bottom: 10px;
    /deep/ .el-button {
      color: #fff;
      background-color: #2F4554;
    }
    /deep/ .el-button.is-disabled {
      color: #ccc;
      border-color: #ccc;
      background-color: #fff;
    }

  }
  .pdL10 {
    padding-left: 10px !important;
  }
  .mgB15 {
    margin-bottom: 15px !important;
  }
  .border-left {
    border-left: 3px #ddd solid !important;
  }
  .font-bold {
    font-weight: 700;
  }
  .form-group {
    margin-bottom: 15px !important;
    margin-right: -0px !important;
    margin-left: -0px !important;
  }
  .form-horizontal .control-label {
    padding-top: 5px;
    margin-bottom: 0;
    text-align: right;
  }
  .form-horizontal div {
    font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif,
    "Regular", "Microsoft YaHei";
    font-size: 12px;
    color: #666666;
    background-color: transparent;
    -webkit-font-smoothing: antialiased;
    line-height: 1.42857143;
    word-wrap: break-word;
  }
  .form-horizontal .control-label {
    padding-top: 3px !important;
  }
  .form-group .pdt3px {
    padding-top: 3px;
  }
  .b-b {
    border-bottom: 1px solid #dddddd;
  }
  .line-dashed {
    border-style: dashed !important;
    background-color: transparent;
    border-width: 0;
  }
  .line-lg {
    margin-top: 15px;
    margin-bottom: 15px;
  }
  .line {
    width: 100%;
    height: 2px;
    margin: 10px 0;
    font-size: 0;
    overflow: hidden;
  }
  table {
    background-color: transparent;
  }
  table {
    border-spacing: 0;
    border-collapse: collapse;
  }
  .mgt15 {
    margin-top: 15px;
  }
  .lineDev{
    border-bottom: 1px solid #dddddd;
    border-style: dashed !important;
    background-color: transparent;
    border-top-width: 0px;
    border-right-width: 0px;
    border-left-width: 0px;
    margin-bottom: 10px!important;
  }

  .title{
      font-weight: 700;
      border-left: 4px solid #ddd;
      padding-left: 10px;
  }
  .item{
      padding-left: 10%;
  }
  .inputWidth{
      width: 30%;
  }
  .one{
    /deep/ .el-form-item__content{
      margin-left: 0 !important; 
    }
  /deep/ .delete{
    margin:0 500px 10px 0;
  }
  }
  
 /deep/ .el-input--mini {
    .el-input__inner{
      width: 200px;
    }
  }
  
</style>
